<template>
    <router-view></router-view>
</template>

<script>
import { defineComponent } from '@vue/runtime-core'
import { getKey } from '@/utils/helper'
import { useStore } from 'vuex'

export default defineComponent({
    setup() {
		// 初始化缓存数据：新闻列表、搜索列表、索引
		let homeIndex = getKey('homeIndex')
		let searchResult = getKey('searchResult')
		let homePageList = getKey('homepage')
		let channelList = getKey('channelList')

		const store = useStore()
		if (channelList) {
			store.commit('updateNewsChannel', { list: JSON.parse(channelList) })
		}

		if (homeIndex) {
			store.commit('updateHomeIndex', homeIndex)
		}

		if (searchResult) {
			store.commit('updateSearchResult', { list: JSON.parse(searchResult) })
		}

		if (homePageList) {
			store.commit('initHomepageList', JSON.parse(homePageList))
		}
	}
})
</script>

<style scoped>

</style>
